package com.lsh.oms.core.dao.other;

import com.lsh.oms.core.dao.MyBatisRepository;
import com.lsh.oms.core.records.core.Return;
import com.lsh.oms.core.records.core.ReturnRequest;
import com.lsh.oms.core.service.tool.Criteria;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@MyBatisRepository
public interface ReturnMapper {

    void insert(@Param("return_request") ReturnRequest returnRequest, @Param("request") Map<String, Object> request);

    void insertDetails(@Param("return_request") ReturnRequest returnRequest,
                       @Param("return_details") List<Map<String, Object>> returnDetails);

    Return findById(@Param("id") Long id);

    Return.ReturnDetail findDetail(@Param("detail_id") Long detailId);

    List<Return.ReturnDetail> findDetails(@Param("return_ids") Collection<Long> returnIds);

    List<Return> findBaseOnCriteria(@Param("criteria") Criteria criteria, @Param("start") long start, @Param("limit") long limit);

    Long countBaseOnCriteria(@Param("criteria") Criteria criteria);

    List<Map<String, Object>> groupByStatus(@Param("criteria") Criteria criteria);

    int updateDraftOfCheck(@Param("return") Return r);

    int updateStatus(@Param("request") Map<String, Object> request,
                     @Param("return") Return r,
                     @Param("base_statuses") Return.Status[] baseStatuses);

    int updateRefund(@Param("return") Return record);

    int updateDetailReturnedQuantity(@Param("detail_id") Long id, @Param("quantity") BigDecimal quantity);

    int updateDetailActualQuantity(@Param("detail_id") Long id, @Param("quantity") BigDecimal quantity);

    int updateDetail(@Param("detail_id") Long id, @Param("request") Map<String, Object> request);
}